********************************************************************************
clear

use "$clean/who_counts_mechanisms.dta"

** Mechanisms, Full Table, Population Census **

** Regressions **

xi: reghdfe prcnt_etat_civil prcnt_for_1970 prcnt_modern_houses mean_elev cropland_1910 popd_1910 n_schools_52 n_classes_52 n_students_52, a(type_factor province colonizer) cluster(name_1972_final)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_EC

xi: reghdfe prcnt_students_male prcnt_etat_civil prcnt_for_1970 prcnt_modern_houses mean_elev cropland_1910 popd_1910 n_schools_52 n_classes_52 n_students_52, a(type_factor province colonizer) cluster(name_1972_final)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_male

xi: reghdfe prcnt_students_female prcnt_etat_civil prcnt_for_1970 prcnt_modern_houses mean_elev cropland_1910 popd_1910 n_schools_52 n_classes_52 n_students_52, a(type_factor province colonizer) cluster(name_1972_final)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_female

** Output Table **
#delimit ; 
estout m_EC
	   m_male
	   m_female
       using "${output}/tables/TableA22.tex",
       style(tex) 
       cells(b(star fmt(3)) se(par fmt(3))) 
varlabels(prcnt_etat_civil "Share Registered Households " prcnt_students_male "Share Male Students"  prcnt_students_female "Share Female Students" prcnt_for_1970 "Share Foreign Population" prcnt_modern_houses "Share Modern Houses" mean_elev "Mean Elevation" cropland_1910 "Estimated Precolonial Cropland" popd_1910 "Estimate Precolonial Population Density " n_schools_52 "N Schools, 1952" n_classes_52 "N Classes, 1952" n_students_52 "N Students, 1952")
       drop(_cons)
	   stats(controls
	   adminFE
             r2 
             N
			 ymean, fmt(0 0 2 0 3 %9.0gc %9.0gc)
             labels("\hline Controls"
			 "\hline Admin FE"
                   "\hline \(R^2\)" 
                  " \hline N"
				   "Dep. Var. Mean "))
       mlabels(,none) 
       numbers
       collabels(none) 
       starl(* 0.1 ** 0.05 *** 0.01)
	          prehead( 
           \begin{table}[H]
           \caption{European Settlement, Registration, and Enrollment, 1970}        
           \label{tab:MECH_1970_FULL}            
           \centering
           \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 
           \hline \hline             
		   & \multicolumn{1}{c}{Registered Households} 
		   & \multicolumn{1}{c}{Enrollment, Men} 
		   & \multicolumn{1}{c}{Enrollment, Women} \\                         
       )
       posthead(\hline) 
       prefoot() 
       postfoot(
           \noalign{\smallskip} \hline \hline 
           \end{tabular}
           \medskip
           \begin{minipage}{.9\textwidth}
           \tiny \justify Notes: \( @starlegend \). 
           \\ Provincial Fixed Effects and Clustered Robust Standard Errors at Locality.
           \end{minipage}        
       \end{table}
       )
       replace;
#delimit cr
